using System;
using System.Windows.Forms;

namespace pal.SvnConf.GUI
{
    public partial class NewUserControl : UserControl
    {
        private UserCreationHandler _userCreationHandler;

        public NewUserControl()
        {
            InitializeComponent();
        }

        private void OnCreateUserClick(object sender, EventArgs e)
        {
            if (_txtPassword.Text != _txtConfirm.Text)
            {
                MessageBox.Show("Passwords don't match");
                return;
            }

            if (_userCreationHandler != null)
                _userCreationHandler(_txtUser.Text, _txtPassword.Text);
        }

        public event UserCreationHandler OnCreateUser
        {
            add { _userCreationHandler += value; }
            remove { _userCreationHandler -= value; }
        }
    }

    public delegate void UserCreationHandler(string userName, string password);
}